package com.hdoit.kylin.logical.baseInfo.model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Entity;
import javax.persistence.Transient;

import com.tennetcn.common.message.ModelBase;
/**
 * @author      guoshuren
 * @email       
 * @createtime  2018年03月03日 17:24:02
 * @comment
 */
@Entity
@Table(name="data_term")
public class Term extends ModelBase{
    //序号
    @Id
    @Column(name="termId")
    private String termId;

    //创建时间
    @Column(name="createDate")
    private Date createDate;

    //学期名称
    @Column(name="termName")
    private String termName;

    //学期开始时间
    @Column(name="startDate")
    private Date startDate;

    //学期结束时间
    @Column(name="endDate")
    private Date endDate;

    @Transient
    private List<Date> weekDates; 
    
    public List<Date> getWeekDates() {
		return weekDates;
	}
	public void setWeekDates(List<Date> weekDates) {
		this.weekDates = weekDates;
	}
	public String getTermId(){
        return this.termId;
    }
    public void setTermId(String termId){
         this.termId=termId;
    }

    public Date getCreateDate(){
        return this.createDate;
    }
    public void setCreateDate(Date createDate){
         this.createDate=createDate;
    }

    public String getTermName(){
        return this.termName;
    }
    public void setTermName(String TermName){
         this.termName=TermName;
    }

    public Date getStartDate(){
        return this.startDate;
    }
    public void setStartDate(Date startDate){
         this.startDate=startDate;
    }

    public Date getEndDate(){
        return this.endDate;
    }
    public void setEndDate(Date endDate){
         this.endDate=endDate;
    }

    public void generateDateList(){
    	weekDates = new ArrayList<Date>();
    	Calendar calendar = Calendar.getInstance();
    	calendar.setTime(startDate);
    	calendar.add(Calendar.DATE, 6);
    	Date date = calendar.getTime();
    	this.weekDates.add(date);
    	while(date.before(endDate)){
    		
    		calendar.add(Calendar.DATE, 7);
    		date = calendar.getTime();
    		this.weekDates.add(date);
    	}
    } 
}
